package com.dongdongshop.controller;

import com.dongdongshop.domain.AjaxResult;
import com.dongdongshop.pojo.TbOrder;
import com.dongdongshop.pojo.TbUser;
import com.dongdongshop.service.OrderService;
import com.dongdongshop.vo.AlipayVO;
import em.ResuleEnum;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.shiro.SecurityUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("order")
public class OrderController {

    @DubboReference
    private OrderService orderService;

    @RequestMapping("saveInfo")
    @ResponseBody
    public AjaxResult saveInfo(Long addrId,String payType){
        TbUser user = (TbUser) SecurityUtils.getSubject().getPrincipal();
        if (user == null){
            return AjaxResult.R(ResuleEnum.ERROR);
        }
        orderService.saveInfo(addrId,payType,user);
        return AjaxResult.R(ResuleEnum.SUCCESS);
    }

}
